package c.a.md.androidvideo.gles;

import android.app.ActivityManager;
import android.content.Context;
import android.content.pm.ConfigurationInfo;
import android.opengl.GLSurfaceView;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.widget.Toast;

public class Step1Activity extends AppCompatActivity
{

    private GLSurfaceView surfaceView;
    private TriangleRender glReder;


    @Override
    protected void onCreate(Bundle savedInstanceState)
    {
        super.onCreate(savedInstanceState);
        checkWhetherSupportOpenGL2();
    }

    private void checkWhetherSupportOpenGL2()
    {
        ActivityManager am = (ActivityManager) getSystemService(Context.ACTIVITY_SERVICE);
        ConfigurationInfo info = am.getDeviceConfigurationInfo();
        if(info.reqGlEsVersion >= 0x20000)
        {
            next();
        }else
        {
            Toast.makeText(this, "not support opengles 2.0", Toast.LENGTH_SHORT).show();
        }
    }

    private void next()
    {
        GLSurfaceView surface = new GLSurfaceView(this);
        surface.setEGLContextClientVersion(2);
        setContentView(surface);

    }
}
